home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / libs / winlib-0.0 / winlib-0 / win / handler.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-02  |  2.1 KB  |  86 lines

  1. /*
  2.  * WinLIB
  3.  * Internal library handler
  4.  */
  5.  
  6. #include "winlib.h"
  7. #include "internal.h"
  8. #include "config.h"
  9.  
  10. int Win_LibHandler(Gpm_Event *event, void *data)
  11. {
  12.     /* Fit all mouse events into the screen instead of one outside the
  13.        margin, as GPM defaults to */
  14.     Gpm_FitEvent(event);
  15.  
  16. #ifdef    MOUSE_COORD
  17.     /* Display event-specific info */
  18.     if (_has_menu) {
  19.     wattron(_menu_win, A_REVERSE);
  20.     mvwprintw(_menu_win, 0, 40, "%03dX %02dY %02d %04x %01d %02d %d",
  21.         event->x, event->y, event->buttons, event->type, _cur_title,
  22.         _cur_window, _resize_corner);
  23.     wattroff(_menu_win, A_REVERSE);
  24.     }
  25. #endif
  26.  
  27.     /* Dispatch to menu handling routine if necessary */
  28.     if ((_has_menu) && (event->y == 0) && (!_moving_win) && (!_resizing_win))
  29.     if ((event->buttons == GPM_B_LEFT) &&
  30.         (event->type & (GPM_DOWN | GPM_DRAG))) {
  31.         if ((_showing_menu) && (_cur_item != -1))
  32.         _unselect_item();
  33.  
  34.         _handle_menu(event);
  35.     } else
  36.         _unselect_menu();
  37.  
  38.     /* Now check to see if our mouse is within the bounds of the dropdown
  39.        menu if it's present. */
  40.     if ((_has_menu) && (_showing_menu) && (!_moving_win) && (!_resizing_win)) {
  41.     if ((event->y >= _menu_area->_begy) &&
  42.         (event->y <= (_menu_area->_begy + _menu_area->_maxy)) &&
  43.         (event->x >= _menu_area->_begx) &&
  44.         (event->x <= (_menu_area->_begx + _menu_area->_maxx)))
  45.         _handle_menu_selection(event);
  46.     else
  47.         _unselect_item();
  48.     }
  49.  
  50.     /* Check to see if the mouse was released in any menus */
  51.     if ((_has_menu) && (_showing_menu) && (_cur_item == -1) &&
  52.     (!(event->type & (GPM_DOWN | GPM_DRAG))) && (!_resizing_win))
  53.     _unselect_menu();
  54.  
  55.     /* Now, check to see whether we've clicked on a window or not */
  56.     if (_has_win) {
  57.     if (!_moving_win)
  58.         _handle_resize(event);
  59.  
  60.     if (!_resizing_win)
  61.         _handle_window(event);
  62.     }
  63.  
  64.     /* Call the mouse dispatcher in case one exists */
  65.     if (_mousedispatch)
  66.     (_mousedispatch)(event);
  67.  
  68.     /* Redraw the screen with the update panels at the very last. */
  69.     update_panels();
  70.     doupdate();
  71.  
  72.     return(TRUE);
  73. }
  74.  
  75. void Win_Loop(void)
  76. {
  77.     int c;
  78.  
  79.     while((c = Gpm_Getch()) != EOF) {
  80.     if (_keydispatch) {
  81.         if (c != 1)
  82.         (_keydispatch)(c);
  83.     }
  84.     }
  85. }
  86.